﻿<Window x:Class="TeacherLoad.Windows.UchebPlanList"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TeacherLoad.Windows"
        mc:Ignorable="d"
        Title="Учебные планы"
        Height="600" Width="1000"
        MinHeight="600" MinWidth="1000"
        WindowStartupLocation="CenterScreen"
        Background="#DFF7E9"
        GotFocus="Window_GotFocus">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="25"/>
        </Grid.RowDefinitions>

        <GroupBox x:Name="HeaderPlanAdd"
                  Header="Новый учебный план"
                  BorderBrush="#200772">
            <StackPanel>
                <Label Content="Специальность"/>
                <ComboBox x:Name="cbSpec"
                          ItemsSource="{Binding}"
                          SelectedValuePath="Id"
                          SelectionChanged="cbSpec_SelectionChanged">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="1*"/>
                                        <ColumnDefinition Width="3*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock x:Name="txCodeSpec"
                                               Text="{Binding Path=Code}"
                                               Margin="0"/>
                                    <TextBlock x:Name="txNameSpec"
                                               Grid.Column="1"
                                               Text="{Binding Path=NameSpec}"
                                               Margin="2 0"
                                               TextWrapping="Wrap"/>
                                </Grid>

                                <TextBlock x:Name="txQualif"
                                           Text="{Binding Path=Qualification}"
                                           TextWrapping="Wrap"/>
                            </StackPanel>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>

                <Label Content="Год утверждения учебного плана"/>
                <TextBox x:Name="txYear"
                         Width="80"
                         HorizontalAlignment="Left"
                         PreviewTextInput="txYear_PreviewTextInput"
                         TextChanged="txYear_TextChanged"/>
                
                <Button x:Name="btnAddPlan"
                        Content="Добавить учебный план"
                        Click="btnAddPlan_Click"/>
                <Button x:Name="btnCancelEditPlan"
                        Content="Отменить редактирование"
                        Visibility="Collapsed"
                        Click="btnCancelEditPlan_Click"/>
                <Button x:Name="ClearEdit"
                        Content="Очистить поля ввода"
                        Click="ClearEdit_Click"
                        Visibility="Collapsed"/>
            </StackPanel>
        </GroupBox>

        <!--Список уч.планов-->
        <GroupBox Grid.Column="0" Grid.Row="1"
                  Header="Список учебных планов">
            <Grid>
                <ListBox x:Name="listPlan"
                         ItemsSource="{Binding}"
                         SelectionChanged="listPlan_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Path=Name}"
                                           FontWeight="Bold"/>
                                <TextBlock x:Name="txYear"
                                           Margin="15,0,0,0"
                                           Text="{Binding Path=BeginYearStr}"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <ListBox.ContextMenu>
                        <ContextMenu>
                            <MenuItem x:Name="ChangeRow"
                                      Header="Изменить строку"
                                      Click="ChangeRow_Click"/>
                        </ContextMenu>
                    </ListBox.ContextMenu>
                </ListBox>
            </Grid>
        </GroupBox>

        <!--Блок добавления данных в уч.план-->
        <GroupBox Grid.Column="1"
                  Header="Добавление данных в учебный план">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <!--Строка 1-->
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="120"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="170"/>

                    </Grid.ColumnDefinitions>
                    <StackPanel>
                        <Label Content="Индекс"/>
                        <TextBox x:Name="txIndex"/>
                    </StackPanel>
                    <StackPanel Grid.Column="1">
                        <Label Content="Предмет"/>
                        <ComboBox x:Name="cbItem"
                                  ItemsSource="{Binding}"
                                  IsEditable="True"/>
                        <StackPanel Orientation="Horizontal">
                            <CheckBox x:Name="IsPractice" Content="Практика" 
                                      VerticalAlignment="Center" 
                                      Margin="5"
                                      IsTabStop="False"/>
                            <Button x:Name="btnAddItem" Content="Добавить новую дисциплину"
                                    Click="btnAddItem_Click"
                                    Margin="50, 0" IsTabStop="False"/>
                        </StackPanel>
                    </StackPanel>
                    <GroupBox Grid.Column="2" Header="Вид аттестации">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <StackPanel>
                                    <Label Content="Зач"/>
                                    <TextBox x:Name="txZach"
                                             PreviewTextInput="hours_PreviewTextInput"/>
                                </StackPanel>
                                <StackPanel Grid.Column="1">
                                    <Label Content="ДЗ"/>
                                    <TextBox x:Name="txDZach"
                                             PreviewTextInput="hours_PreviewTextInput"/>
                                </StackPanel>
                                <StackPanel Grid.Column="2">
                                    <Label Content="Экз"/>
                                    <TextBox x:Name="txEkz"
                                             PreviewTextInput="hours_PreviewTextInput"/>
                                </StackPanel>
                            </Grid>
                    </GroupBox>
                </Grid>

                <!--Тестовая функция-->
                <WrapPanel Grid.Row="1">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="60"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="60"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="60"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="70"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="30"/>
                        </Grid.RowDefinitions>
                        <Label Content="Учебные часы по дисциплине"
                               Grid.ColumnSpan="3"/>
                        <Label Grid.Row="1" Content="Теория" HorizontalAlignment="Right"/>
                        <TextBox x:Name="txTeor" Grid.Row="1" Grid.Column="1"
                                 PreviewTextInput="hours_PreviewTextInput"/>

                        <Label Content="Практика" Grid.Row="2" HorizontalAlignment="Right"/>
                        <TextBox x:Name="txPract" Grid.Column="1" Grid.Row="2"
                                 PreviewTextInput="hours_PreviewTextInput"/>

                        <Label Grid.Column="2" Grid.Row="1"  Content="Консультация" HorizontalAlignment="Right"/>
                        <TextBox x:Name="txConsult" Grid.Column="3" Grid.Row="1" 
                                 PreviewTextInput="hours_PreviewTextInput"/>

                        <Label Grid.Row="2" Grid.Column="2" Content="Аттестация" HorizontalAlignment="Right"/>
                        <TextBox x:Name="txAttest" Grid.Column="3" Grid.Row="2" PreviewTextInput="hours_PreviewTextInput"/>

                        <Label Grid.Column="4" Grid.Row="1" Content="Сам. работа"/>
                        <TextBox x:Name="txSelf" Grid.Column="5" Grid.Row="1"
                                 PreviewTextInput="hours_PreviewTextInput"/>

                        <Label Grid.Column="6" Grid.Row="1" Content="Всего часов" HorizontalAlignment="Right"/>
                        <TextBox x:Name="txTotal" Grid.Column="7" Grid.Row="1" IsReadOnly="True" IsTabStop="False"/>
                    </Grid>

                    <Grid Margin="10 0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="80"/>
                            <ColumnDefinition Width="80"/>
                            <ColumnDefinition Width="80"/>
                            <ColumnDefinition Width="80"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Label Grid.Row="1" Content="1 полугодие" HorizontalContentAlignment="Right"/>
                        <Label Grid.Row="2" Content="2 полугодие" HorizontalContentAlignment="Right"/>

                        <Label Grid.Column="1" Content="1 курс" HorizontalAlignment="Center"/>
                        <TextBox x:Name="sem1" Grid.Row="1" Grid.Column="1" ToolTip="1 семестр"
                                 PreviewTextInput="hours_PreviewTextInput"/>
                        <TextBox x:Name="sem2" Grid.Row="2" Grid.Column="1" ToolTip="2 семестр"
                                 PreviewTextInput="hours_PreviewTextInput"/>

                        <Label Grid.Column="2" Content="2 курс" HorizontalAlignment="Center"/>
                        <TextBox x:Name="sem3" Grid.Row="1" Grid.Column="2" ToolTip="3 семестр"
                                 PreviewTextInput="hours_PreviewTextInput"/>
                        <TextBox x:Name="sem4" Grid.Row="2" Grid.Column="2" ToolTip="4 семестр"
                                 PreviewTextInput="hours_PreviewTextInput"/>

                        <Label Grid.Column="3" Content="3 курс" HorizontalAlignment="Center"/>
                        <TextBox x:Name="sem5" Grid.Row="1" Grid.Column="3" ToolTip="5 семестр"
                                 PreviewTextInput="hours_PreviewTextInput"/>
                        <TextBox x:Name="sem6" Grid.Row="2" Grid.Column="3" ToolTip="6 семестр"
                                 PreviewTextInput="hours_PreviewTextInput"/>

                        <Label Grid.Column="4" Content="4 курс" HorizontalAlignment="Center"/>
                        <TextBox x:Name="sem7" Grid.Row="1" Grid.Column="4" ToolTip="7 семестр" 
                                 PreviewTextInput="hours_PreviewTextInput"/>
                        <TextBox x:Name="sem8" Grid.Row="2" Grid.Column="4" ToolTip="8 семестр" 
                                 PreviewTextInput="hours_PreviewTextInput"/>

                    </Grid>
                    
                </WrapPanel>
                <StackPanel Grid.Row="2" Orientation="Horizontal"
                            HorizontalAlignment="Right">
                    <Button x:Name="btnClear"  Content="Очистить данные" 
                            HorizontalAlignment="Right"
                            VerticalAlignment="Bottom"
                            Width="150" Margin="10 0"
                            Visibility="Visible"
                            Click="btnClear_Click"
                            IsTabStop="False"/>
                    <Button Content="Добавить данные" 
                            HorizontalAlignment="Right"
                            VerticalAlignment="Bottom"
                            Width="150" Margin="10 0"
                            Visibility="Visible"
                            IsTabStop="False"/>
                </StackPanel>
                

                <!--Строка 2-->
                <!--<Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="60"/>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="60"/>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="60"/>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="70"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Label Content="Теория" HorizontalAlignment="Right"/>
                    <TextBox Grid.Column="1"/>

                    <Label Content="Практика" Grid.Row="1" HorizontalAlignment="Right"/>
                    <TextBox Grid.Column="1" Grid.Row="1"/>
                    
                    <Label Grid.Column="2" Content="Консультация" HorizontalAlignment="Right"/>
                    <TextBox Grid.Column="3"/>

                    <Label Grid.Row="1" Grid.Column="2" Content="Аттестация" HorizontalAlignment="Right"/>
                    <TextBox Grid.Column="3" Grid.Row="1"/>
                    
                    <Label Grid.Column="4" Content="Сам. работа"/>
                    <TextBox Grid.Column="5"/>

                    <Label Grid.Column="6" Content="Всего часов" HorizontalAlignment="Right"/>
                    <TextBox Grid.Column="7" IsReadOnly="True" IsTabStop="False"/>
                    
                    <Label Grid.Column="6" Grid.Row="1" Content="Макс. нагрузка"/>
                    <TextBox Grid.Column="7" Grid.Row="1" IsReadOnly="True" IsTabStop="False"/>

                </Grid>-->
                
                <!--Строка 3-->
                <!--<Grid Grid.Row="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="80"/>
                        <ColumnDefinition Width="80"/>
                        <ColumnDefinition Width="80"/>
                        <ColumnDefinition Width="80"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Label Grid.Row="1" Content="1 полугодие" HorizontalContentAlignment="Right"/>
                    <Label Grid.Row="2" Content="2 полугодие" HorizontalContentAlignment="Right"/>

                    <Label Grid.Column="1" Content="1 курс" HorizontalAlignment="Center"/>
                    <TextBox Grid.Row="1" Grid.Column="1"/>
                    <TextBox Grid.Row="2" Grid.Column="1"/>

                    <Label Grid.Column="2" Content="2 курс" HorizontalAlignment="Center"/>
                    <TextBox Grid.Row="1" Grid.Column="2" />
                    <TextBox Grid.Row="2" Grid.Column="2" />

                    <Label Grid.Column="3" Content="3 курс" HorizontalAlignment="Center"/>
                    <TextBox Grid.Row="1" Grid.Column="3" />
                    <TextBox Grid.Row="2" Grid.Column="3" />

                    <Label Grid.Column="4" Content="4 курс" HorizontalAlignment="Center"/>
                    <TextBox Grid.Row="1" Grid.Column="4" />
                    <TextBox Grid.Row="2" Grid.Column="4" />

                    <Button Content="Добавить данные" 
                            Grid.Column="5" Grid.Row="2"
                            HorizontalAlignment="Right"
                            Width="150" Margin="10 0"/>
                </Grid>-->
            </Grid>
        </GroupBox>
        
        <!--Учебный план-->
        <GroupBox Grid.Row="1" Grid.Column="1"
                  Header="Содержание учебного плана">
            <DataGrid>
                
            </DataGrid>
        </GroupBox>
        
        <!--Информация-->
        <StatusBar Grid.Row="2" Grid.ColumnSpan="2" Background="#BFF7E9">
            <StatusBarItem>
                <TextBlock Text="{Binding StringFormat=Количество строк: {0},
                           ElementName=listPlan, Path=Items.Count}"
                           Margin="5 0"/>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>
